import { createApp } from 'vue'
import App from './App.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
//@ts-ignore忽略当前文件ts类型的检测否则有红色提示(打包会失败)
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
// 引入所有图标
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import 'virtual:svg-icons-register'
import gloablComponent from '@/components/index'
// 引入全局样式
import '@/styles/index.scss'
// 引入路由
import router from './router'
// 引入路由鉴权
import './permission'

// 引入数据仓库
import pinia from './store'
// 引入组件通信
import emitter from './mitt'

// 引入localstorage
import localStorageInstance from '@/utils/localStorage'

const app = createApp(App)
// 注册所有图标为全局组件
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
app.use(ElementPlus, {
  locale: zhCn,
})
app.use(gloablComponent)
// 注册路由
app.use(router)
// 注册仓库
app.use(pinia)
app.mount('#app')

// 注册全局变量
app.config.globalProperties.$localStorageInstance = localStorageInstance
app.config.globalProperties.$emitter = emitter
export const globals = app.config.globalProperties
